using System;
using Unity.Entities;

namespace Game.Core
{
    [Flags]
    public enum PropertySource : byte
    {
        Invalid = 0, 
        
        Character = 1 << 0,
        Weapon = 1 << 1,
        Equip = 1 << 2,
        Ability = 1 << 3,
        Buff = 1 << 4,
        
        All = 255,
    }
    
    public enum PropertyType : byte
    {
        Default = 0,
        
        // Advanced Attribute
        Strength = 1,
        Dexterity,
        Constitution,
        Intellectual,
        Lucky,
        Charisma,
        
        // Property Base Value
        CurEncumbered = 10,
        MaxEncumbered,
        CurHealthPoint,
        MaxHealthPoint,
        HealthRecover,
        AbilityPower,
        CurAbilityPoint,
        MaxAbilityPoint,
        AbilityRecover,
        AttackRange,
        AttackSpeed, 
        AttackInterval,
        MinMeleeAttack,
        MaxMeleeAttack,
        MinRangeAttack,
        MaxRangeAttack,
        Armor,
        Resistance,
        Penetration,
        Block,
        Dodge,
        Hit,
        CritRate,
        CritRatio,
        Resilience,
        ExtraDamage,
        MaxTroops,
        
        MoveSpeed,
        RotateSpeed,
    }

    [Flags]
    public enum PropertyRefresh : byte
    {
        None,
        Base = 1 << 0,
        Attackable = 1 << 1,
        Damageable = 1 << 2,
        Movable = 1 << 3,
        Init = 0x0F,
        All = 0xFF,
    }

    public unsafe struct Property
    {
        public PropertySource Source;
        public PropertyType Type;
        public float Value;
    }

    public unsafe struct PropertyData : IComponentData
    {
        public uint ID;
        public PropertyRefresh Refresh; 
        public PropertyInfo Base;
        // public PropertyInfo Current;
        public AdvancedPropertyData Advanced;
    }

    public enum PropertyModifyType : byte
    {
        Base,
        Real,
    }
    
    public unsafe struct PropertyModifier : IBufferElementData
    {
        public PropertyModifyType ModifyType;
        public Property Property;
    }
    
    public unsafe struct StaticProperty : IBufferElementData
    {
        public PropertySource Source;
        public ulong Value;
    }
    
    public unsafe struct BaseProperty : IBufferElementData
    {
        public Property Property;
    }

    public unsafe struct DynamicProperty : IBufferElementData
    {
        public Property Property;
    }
}